package com.coolingme.general;

/**
 * 观察者测试
 *
 * @author wangyue
 * @date 2020-10-01 23:11
 */
public class Test {

    public static void main(String[] args) {
        // 被观察者
        ISubject<String> subject = new ConcreteSubject<>();

        // 观察者
        IObserver<String> observer1 = new ConcreteObserver<>();
        IObserver<String> observer2 = new ConcreteObserver<>();

        // 注册
        subject.attach(observer1);
        subject.attach(observer2);

        // 通知
        subject.notify("Hello,Observer");
    }

}
